<?php
/**
 * Here is your custom functions.
 */
use app\util\ReturnCode;

/**
 * [success description]
 * @param  [type]  $data
 * @param  string  $msg
 * @param  integer $code   1:成功返回；
 * @return [type]
 */
function success($data = [], $msg = 'Success', $code = ReturnCode::SUCCESS){
    return json([
        'code' => $code,
        'data' => $data,
        'message' => $msg,
    ]);
}
/**
 * [error description]
 * @param  [type]  $data
 * @param  string  $msg
 * @param  integer $code   0:错误返回；
 * @return [type]
 */
function error($msg = 'Error', $code = ReturnCode::ERROR, $data = null){
    return json([
        'code' => $code,
        'data' => $data,
        'message' => $msg,
    ]);
}
